﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using RecruitmentSystem.Business;
using RecruitmentSystem.Common;
using System.Collections.Generic;


public partial class StudentManagement_PositionSearch : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        BindDataList();
        tdResult.Visible = true;
    }


    private void BindDataList()
    {
        if (ddlPoitionType.Value != "")
        {
            string workprovince;
            string workdistrict;
            if (ddlWorkProvince.SelectedValue == "不限")
            {
                workprovince = null;
                workdistrict = null;
            }
            else if (ddlWorkProvince.SelectedValue == "上海")
            {
                if (ddlWorkDistrict.SelectedValue == "不限")
                {
                    workprovince = "上海";
                    workdistrict = null;
                }
                else
                {
                    workprovince = "上海";
                    workdistrict = ddlWorkDistrict.SelectedValue;
                }
            }
            else
            {
                if (txtOtherArea.Text.Trim() == "")
                {
                    workprovince = "其他";
                    workdistrict = null;
                }
                else
                {
                    workprovince = "其他";
                    workdistrict = ddlWorkDistrict.SelectedValue;
                }
            }

            string positiontype = ddlPoitionType.Value;
            string salary = null;
            if (ddlSalary.SelectedValue != "")
            {
                salary = ddlSalary.SelectedItem.Text;
            }
            string gender = null;
            if (ddlGender.SelectedValue != "0")
            {
                gender = ddlGender.SelectedItem.Text;
            }
            string workmethod = null;
            if (ddlWorkMethod.SelectedValue != "0")
            {
                workmethod = ddlWorkMethod.SelectedItem.Text;
            }

            string enterprisedustry = null;
            if (ddlEnterpriseindustry.Value != "0")
            {
                enterprisedustry = ddlEnterpriseindustry.Items[ddlEnterpriseindustry.SelectedIndex].Text;
            }
            string enterpriseproperity = null;
            if (ddlEnterpriseProperity.Value != "0")
            {
                enterpriseproperity = ddlEnterpriseProperity.Items[ddlEnterpriseProperity.SelectedIndex].Text;
            }
            string titlekey = null;
            if (txtTitle.Text.Trim() != "")
            {
                titlekey = txtTitle.Text;
            }
            JobManager jm = new JobManager();
            AspNetPager1.RecordCount = jm.GetPositionsCount(positiontype, workprovince, workdistrict, salary, gender, workmethod, titlekey, enterpriseproperity, enterprisedustry);
            DataList1.DataSource = jm.SearchJobs(positiontype, workprovince, workdistrict, salary, gender, workmethod, titlekey, enterpriseproperity, enterprisedustry, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize);
            DataList1.DataBind();
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "empty", "<script type='text/javascript'>alert('请您选择职位类别！');</script>");
            return;
        }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindDataList();
    }
}
